package com.wchen.project.zk.zkclient;

import org.I0Itec.zkclient.ZkClient;

/**
 * @Desc:   使用ZkClient创建会话
 * @author: cww
 * @DateTime: 2020-01-20 18:41
 */

public class ZooKeeperSessionByZkClient {
    public static void main(String[] args) {
        ZkClient zkClient = new ZkClient("home:2181", 5000);
        String path = "/zk-book/c1/c2";
        // true:在创建一个节点之前先去检查父节点是否存在，如果不存在，那么先创建父节点,
        zkClient.createPersistent(path, true);
        // 允许直接删除某一级，即使这一级下面有 children
        zkClient.deleteRecursive("/zk-book/c1");
        System.out.println("Zookeeper session established.");
    }
}
